// MenuService的实现类  
package org.example.service.impl;

import ch.qos.logback.classic.spi.EventArgUtil;
import org.example.common.entity.Menu;
import org.example.mapper.MenuMapper;
import org.example.service.MenuService;
import org.example.util.MenuTreeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;  
  
import java.util.List;  
  
@Service  
public class MenuServiceImpl implements MenuService {
  
    @Autowired  
    private MenuMapper menuMapper;
  
    @Override  
    public int insertMenu(Menu menu) {
        menu.setStatus("1");
        return menuMapper.insertMenu(menu);  
    }  
  
    @Override  
    public Menu selectMenuById(String id) {  
        return menuMapper.selectMenuById(id);  
    }  
  
    @Override  
    public List<Menu> selectAllMenus() {
        List<Menu> menus = menuMapper.selectAllMenus();
        List<Menu> menuTree = MenuTreeUtil.getMenuTree(menus);
        return menuTree;
    }  
  
    @Override  
    public int updateMenu(Menu menu) {  
        return menuMapper.updateMenu(menu);  
    }  
  
    @Override  
    public int deleteMenu(String id) {  
        return menuMapper.deleteMenu(id);  
    }

    @Override
    public Object listByUserId(long loginIdAsLong) {
        return menuMapper.selectByUserAllMenus(loginIdAsLong);
    }

    // 其他业务逻辑实现...  
}